// pages/contents/contents.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  onMytap:(event)=>{
    console.log("点击自定义组件触发的事件: "+event.currentTarget.dataset.id);
    console.log("点击自定义组件触发detail: "+JSON.stringify(event.detail));
  },

  buttonClick:(e)=>{
    console.log("点击自定义组件中的按钮触发："+JSON.stringify(e.detail));
  },
  movableViewTap:(e)=>{
    wx.navigateTo({
      url: './movable-view/movable-view',
      
    })
  },

  coverViewTap:(e)=>{
    wx.navigateTo({
      url: './cover-view/cover-view',
      
    })
  },

  pickerTap:(e)=>{
    wx.navigateTo({
      url:'./picker/picker'
    })
  },

  mapTap:(e)=>{
    wx.navigateTo({
      url: './map/map',
      
    })
  },

  adressTap:(e)=>{
    wx.chooseAddress({
      success: function (res) {
        console.log(res.userName)
        console.log(res.postalCode)
        console.log(res.provinceName)
        console.log(res.cityName)
        console.log(res.countyName)
        console.log(res.detailInfo)
        console.log(res.nationalCode)
        console.log(res.telNumber)
      }
    })
  },


  loginTap:(e)=>{

    wx.login({
      success:(res)=>{
        if(res.code){
          console.log(res.code);
        }
      }
    })

    wx.checkSession({
      success:()=>{
        console.log("session sucess");
        wx.getUserInfo({
          withCredentials:true,
          success:(res)=>{
            console.log(res);
          },fail:(res)=>{
            console.log(res);
          }
        })
      },

      fail:(res)=>{
        wx.login({
          success: function(res){
            wx.getUserInfo({
              withCredentials:true,
              success:(res)=>{
                console.log(res);
              },fail:(res)=>{
                console.log(res);
              }
            })
          },
          fail: function() {
            // fail
          },
          complete: function() {
            // complete
          }
        })
      }
    })
  },
})